#include <stdio.h>
#include <string.h>
#include <libnet.h>

int main(int argc,char argv[])
{
        char *dev = "eth0";
        char errbuf[LIBNET_ERRBUF_SIZE];
        u_int8_t hwsize = 6;
        u_int8_t prsize = 4;
        u_int16_t ostype = ARPOP_REPLY;
        u_int16_t prtype = 0x0806;
        u_int32_t srcip = inet_addr("172.16.2.241");
        u_int32_t desip = inet_addr("172.168.2.242");
        u_char srcmac[6] = {0xff,0xff,0xff,0xff,0xff,0xff};
        u_char desmac[6];
        libnet_t *plibnet;
        plibnet = libnet_init(LIBNET_LINK_ADV, dev, errbuf);
        libnet_build_arp(ARPHRD_ETHER, ETHERTYPE_IP, hwsize, prsize, ostype, (u_int8_t*)&srcmac, (u_int8_t*)&srcip, (u_int8_t*)&desmac, (u_int8_t*)&desip, NULL, 0, plibnet, 0);
        libnet_build_ethernet(desmac, srcmac, prtype, NULL, 0, plibnet, 0);
	for (;;)
        {
        libnet_write(plibnet);
        printf("Send ARP Packet!\n");
        sleep(1);
        }
        libnet_destroy(plibnet);
        return 0;
}
